<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="keywords" content="admin, dashboard, bootstrap, template, flat, modern, theme, responsive, fluid, retina, backend, html5, css, css3">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <title>{:lang("资金记录列表")}</title>
    <!--common-->
    <link href="/static/css/public/style.css" rel="stylesheet">
    <link href="/static/css/public/style-responsive.css" rel="stylesheet">
    <!--dynamic table-->
    <link href="/static/js/public/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/static/js/public/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/static/js/public/data-tables/DT_bootstrap.css" />
    <link rel="stylesheet" href="/static/plugin/layui/css/layui.css">
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
    <style>
        .layerUpload {
            width: 100%;
            height: 100%;
            position: fixed;
            left: 0;
            top: 0;
            z-index: 10;
            display: none;
        }
        .layerUpload .mask {
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
        }
        .layerUpload .con {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .layerUpload .cons {
            width: 500px;
            height: 500px;
            background-color: #fff;
        }
        .layerUpload .cons .buttonCon {
            display: block;
            margin: 30px auto;
        }
        .layerUpload .textareaBox {
            width: 100%;
            height: 200px;
            margin: 30px 0;
            display: flex;
            justify-content: center;
        }
        .layerUpload .textareaBox textarea {
            width: 90%;
            resize:none;
        }
        .layerUpload .buttonBox {
            display: flex;
            justify-content: flex-end;
        }
    </style>
</head>

<body class="sticky-header">
<!-- 文件上传弹窗 -->
<div class="layerUpload">
    <div class="mask"></div>
    <div class="con">
        <div class="cons">
            <div class="layui-layer-title" id="tip_msg"></div>
            <div>
                <button type="button" class="layui-btn buttonCon" id="file">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <div style="text-align: center; height: 30px;">
                    <a href="" target="_blank" id="file_path" style="display: none">文件已上传</a>
                </div>
                <input type="hidden" name="file" id="file_upload">
                <input type="hidden" name="capital_id" id="capital_id">
                <input type="hidden" name="type" id="type">
            </div>
            <div class="textareaBox">
                <textarea name="" id="text_area" cols="30" rows="10"></textarea>
            </div>
            <div class="layui-layer-btn layui-layer-btn- buttonBox">
                <button class="layui-btn layui-btn-normal" id="sub_btn">确认</button>
                <button class="layui-btn layui-btn-primary" id="close_btn">取消</button>
            </div>
        </div>
    </div>
</div>
<!-- 文件上传弹窗 -->
<!-- 左侧菜单开始-->
{include file="public/nav_left"}
<!-- 左侧菜单结束-->

<!-- main content start-->
<div class="main-content" >

    <!-- 头部菜单开始-->
    {include file="public/nav_top"}
    <!-- 头部菜单结束-->
    <!-- page heading start-->
    <div class="page-heading">
        <h3>
            {:lang("资金记录列表")}
        </h3>
        <!--<ul class="breadcrumb">
            <li>
                <a href="#">产品管理</a>
            </li>
            <li>
                <a href="#">产品列表</a>
            </li>
        </ul>-->
    </div>
    <!-- page heading end-->

    <!--主内容开始-->
    <div class="wrapper">
        <div class="row">
            <div class="col-sm-12">
                <section class="panel">
                    <div class="panel-body">
                        <div class="adv-table">
                             <div class="clearfix">
                             <div class="btn-group">
                             <div style="padding-bottom: 10px;">
                                 <button class="layui-btn layuiadmin-btn-admin" id="export_excel">导出表格</button>
                                 <span style="color: #8D8D8D">(当你勾选记录时则导出被勾选的多条数据,尚未勾选数据时则导出符合筛选条件的所有数据)</span>
                             </div>
                             </div>
                             </div>
                            <div class="row-fluid"><div class="span6">
                                <div id="dynamic-table_length" class="dataTables_length" style="width:100%">
                                    <form name="info" id="info" action="/admin/capital/capitalList/pId/4" method="get">
                                        <label><select class="form-control" size="1" name="page_size" id="page_size" aria-controls="dynamic-table">
                                            <option value="10" {if condition="$param.page_size eq 10"}selected{/if}>10</option>
                                            <option value="25" {if condition="$param.page_size eq 25"}selected{/if}>25</option>
                                            <option value="50" {if condition="$param.page_size eq 50"}selected{/if}>50</option>
                                            <option value="100" {if condition="$param.page_size eq 100"}selected{/if}>100</option>
                                        </select><span>{:lang("每页记录数")} &nbsp;&nbsp;&nbsp;</span> </label>

                                        <select name="user" id="user" style="float:left;width:100px;" class="form-control" size="1" >
                                            <option  value="0">{:lang("用户")}</option>
                                            {volist name="$user_list" key="key1" id="vo1"}
                                            <option  value="{$vo1.dd_user_id}" {if condition="$param.user eq $vo1.dd_user_id"}selected{/if}>{$vo1.name}</option>
                                            {/volist}
                                        </select>
                                        <select name="capital_type" id="capital_type" style="float:left;width:100px;" class="form-control" size="1" >
                                            <option  value="0">{:lang("记录类型")}</option>
                                            {volist name="$capital_type" key="key2" id="vo2"}
                                            <option  value="{$key2}" {if condition="$param.capital_type eq $key2"}selected{/if}>{$vo2}</option>
                                            {/volist}
                                        </select>
                                        <select name="capital_status" id="capital_status" style="float:left;width:100px;" class="form-control" size="1" >
                                            <option  value="0">{:lang("记录状态")}</option>
                                            {volist name="capital_status" key="key3" id="vo3"}
                                            <option  value="{$key3}" {if condition="$param.capital_status eq $key3"}selected{/if}>{$vo3}</option>
                                            {/volist}
                                        </select>

                                        <input name="start_date" id="start_date" value="{$param.start_date}" style="width:150px;float: left"  type="text" class="form-control" size="1" placeholder="起止时间" autocomplete="off">
                                        <input name="end_date" id="end_date" value="{$param.end_date}" style="width:150px;float: left"  type="text" class="form-control" size="1" placeholder="结束时间" autocomplete="off">
                                        &nbsp&nbsp
                                        <div style="display: inline-block" class="btn btn-primary" id="search">搜索</div>
                                        <div style="display: inline-block" class="btn btn-danger" id="clear">重置</div>
                                    </form>
                                </div>
                            <div class="space15"></div>

                            <table class="display table table-bordered table-striped" id="dynamic-table">
                                <thead>
                                <tr>
                                    <th style="width: 3%; text-align: center;"><input type="checkbox" id="check_all" name="" ></th>
                                    <th style="width: 3%; text-align: center;">序号</th>
                                    <th style="width: 4%; text-align: center;">id</th>
                                    <th style="width: 5%;text-align: center;">类型</th>
                                    <th style="width: 5%;text-align: center;">金额</th>
                                    <th style="width: 5%;text-align: center;">账户余额</th>
                                    <th style="width: 8%;text-align: center;">支付宝用户名</th>
                                    <th style="width: 10%;text-align: center;">支付宝账号</th>
                                    <th style="width: 5%;text-align: center;">状态</th>
                                    <th style="width: 10%;text-align: center;">备注</th>
                                    <th style="width: 6%;text-align: center;">添加人</th>
                                    <th style="width: 10%;text-align: center;">添加时间</th>
                                    <th style="width: 10%;text-align: center;">操作</th>
                                </tr>
                                </thead>
                                <tbody id="table">

                                {volist name="list" id="item"}
                                <tr class="gradeA">
                                    <td style="width: 3%; text-align: center;"><input type="checkbox" name="" class="check_item" data-id="{$item.id}" value="{$item.id}"></td>
                                    <td style="width: 3%; text-align: center;">{$key+1}</td>
                                    <td style="width: 4%; text-align: center;">{$item.id}</td>
                                    <td style="width: 5%;text-align: center;">{:get_status_color($capital_type[$item.type], $item.type)}</td>
                                    <td style="width: 5%;text-align: center;">{$item.amount}</td>
                                    <td style="width: 5%;text-align: center;">{$item.capital}</td>
                                    <td style="width: 8%;text-align: center;">{$item.account_user}</td>
                                    <td style="width: 10%;text-align: center;">{$item.account_code}</td>
                                    <td style="width: 5%;text-align: center;">{:get_status_color($capital_status[$item.status], $item.status)}</td>
                                    <td style="width: 10%;text-align: center;">{$item.update_remark}</td>
                                    <td style="width: 6%;text-align: center;">{$item.dd_user_id|get_user_name=###}</td>
                                    <td style="width: 10%;text-align: center;">{$item.create_time}</td>
                                    <td style="width: 10%;text-align: center;">
                                        {if condition="$item.type eq 2 && $item.status eq 2"}
                                            <button class="btn btn-sm btn-success audit_btn" data-id="{$item.id}" data-type="1">通过</button>&nbsp
                                            <button class="btn btn-danger btn-sm audit_btn" data-id="{$item.id}" data-type="2">退回</button>
                                        {/if}
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                            <div style=" text-align:center;">
                                <div class="spen6" style=" float:right;">{$list->render();}</div>
                            </div>
                        </div>
                    </div>
                </section>
            </div>
        </div>




    </div>
    <!--主内容结束-->


</div>
<!-- main content end-->

<!-- Placed js at the end of the document so the pages load faster -->
<script src="/static/js/public/jquery-1.10.2.min.js"></script>
<script src="/static/js/public/jquery-ui-1.9.2.custom.min.js"></script>
<script src="/static/js/public/jquery-migrate-1.2.1.min.js"></script>
<script src="/static/js/public/bootstrap.min.js"></script>
<script src="/static/js/public/modernizr.min.js"></script>
<script src="/static/js/public/jquery.nicescroll.js"></script>
<script src="/static/js/public/layer.js"></script>
<script src="/static/plugin/layui/layui.js"></script>

<!--dynamic table-->
<script src="/static/js/public/advanced-datatable/js/jquery.dataTables.js"></script>
<script src="/static/js/public/data-tables/DT_bootstrap.js"></script>
<!--dynamic table initialization -->
<!--<script src="/static/js/public/dynamic_table_init.js"></script>-->

<!--common scripts for all pages-->
<script src="/static/js/public/scripts.js"></script>

<script>
    $(function(){
        $('.disabled').removeClass().addClass("prev disabled");
        $(".pagination li:first-child").children().html("← 上一页");
        $(".pagination li:last-child").children().html("下一页 → ");
        $("#search").click(function(){
            var page_size = $("#page_size").val();
            var user = $("#user").val();
            var capital_status = $("#capital_status").val();
            var capital_type = $("#capital_type").val();
            var start_date = $("#start_date").val();
            var end_date = $("#end_date").val();
            window.location.href = '/admin/capital/capitalList/pId/4?page_size=' + page_size + '&user=' + user + '&capital_status=' + capital_status + '&capital_type=' + capital_type + '&start_date=' + start_date + '&end_date=' + end_date
        });
        $("#clear").click(function(){
            $("#page_size").val(10);
            $("#user").val(0);
            $("#capital_status").val(0);
            $("#capital_type").val(0);
            $("#start_date").val('');
            $("#end_date").val('');
            window.location.href = '/admin/capital/capitalList/pId/4?'
        });
    });
</script>
<script>
    var data_box = {
        audit_url : "{:url('admin/Capital/auditCapital')}",
        redirect_url : "{:url('admin/Capital/capitalList')}",
        upload_url : "{:url('admin/Capital/uploadFile')}",
    }
    layui.use(['layer', 'upload', 'laydate'], function(){
        var layer = layui.layer
            ,upload = layui.upload
            , laydate = layui.laydate;
        //执行实例
        var uploadInst = upload.render({
            elem: '#file' //绑定元素
            ,url: data_box.upload_url //上传接口
            ,done: function(res){
                //上传完毕回调
                if (res.code == 0) {
                    layui.layer.msg(res.msg);
                    $('#file_path').css('display', 'block');
                    $('#file_path').attr('href', res.data.src);
                    $('#file_upload').val(res.data.src);
                }
            }
            ,error: function(){
                //请求异常回调
                layui.layer.msg("文件上传失败,请重试");
            }
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#start_date' //指定元素
            ,trigger: 'click'
        });
        laydate.render({
            elem: '#end_date' //指定元素
            ,trigger: 'click'
        });
    });
    $(function () {
        // 搜索
        $('#search_btn').click(function(){
            var page_size = $('#page_size').val();
            var user = $('#user').val();
            var capital_type = $('#capital_type').val();
            var capital_status = $('#capital_status').val();
            window.location.href = '/admin/Capital/capitalList?page_size='+page_size+'&user='+user+'&capital_type='+capital_type+'&capital_status='+capital_status;
        })
        // 多选框正反选
        $('#check_all').change(function(){
            if ($('#check_all').attr('checked') === 'checked') {
                $('.check_item').each(function (index, element) {
                    $(element).attr('checked', 'checked');
                })
            } else {
                $('.check_item').each(function (index, element) {
                    $(element).removeAttr('checked');
                })
            }
        })
        // 导出数据
        $('#export_excel').click(function(){
            var checked = $('.check_item:checked');
            if (checked.length > 0) {
                var ids = '';
                checked.each(function (index, element) {
                    ids += $(element).data('id') + '-';
                })
                window.location.href = '/admin/Capital/exportCapital?ids='+ids;
            } else {
                var user = $('#user').val();
                var capital_type = $('#capital_type').val();
                var capital_status = $('#capital_status').val();
                window.location.href = '/admin/Capital/exportCapital?user='+user+'&capital_type='+capital_type+'&capital_status='+capital_status;
            }
        })
        // 审核-弹框
        $('.audit_btn').click(function(){
            var id = $(this).data('id');
            var type = $(this).data('type');
            if (type == 1){
                $('#tip_msg').html('确定通过该条资金审核');
            } else {
                $('#tip_msg').html('确定退回该条资金审核，并确认');
            }
            $('#file_upload').val('');
            $('#capital_id').val(id);
            $('#type').val(type);
            $('#text_area').val('');
            $('.layerUpload').css('display','block');
            $('#file_path').css('display', 'none');
            $('#file_path').attr('href', "");
        })
        // 关闭弹窗
        $('#close_btn').click(function(){
            $('#tip_msg').html('');
            $('#file_upload').val('');
            $('#capital_id').val('');
            $('#text_area').val('');
            $('#type').val("");
            $('.layerUpload').css('display','none');
            $('#file_path').css('display', 'none');
            $('#file_path').attr('href', "");
        })
        // 提交
        $('#sub_btn').click(function(){
            var file = $('#file_upload').val();
            var type = $('#type').val();
            var id = $('#capital_id').val();;
            var remark = $('#text_area').val();
            $.get(data_box.audit_url,{id :id , type: type, file : file, remark : remark}, function(res){
                layui.layer.msg(res.msg);
                if (res.status == 1) {
                    setTimeout(function () {
                        location.href = data_box.redirect_url;
                    }, 1500)
                }
            })
        })
    })
</script>

</body>
</html>